package cn.com.dhcc.app.pub.core.job.monitor;

import org.apache.log4j.Logger;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean.StatefulMethodInvokingJob;

import cn.com.dhcc.app.core.CM;
import cn.com.dhcc.app.core.base.IocBean;
import cn.com.dhcc.app.core.exception.ServiceException;
import cn.com.dhcc.app.core.service.Log;
import cn.com.dhcc.app.core.service.Log.LOGTYPE;
import cn.com.dhcc.app.pub.core.consts.AppConst;
import cn.com.dhcc.turbo.entity.registry.NodeInfo;
import cn.com.dhcc.turbo.service.monitor.gather.FtpServerQuotaGatherService;
import cn.com.dhcc.turbo.service.monitor.gather.NetConnStatusGatherService;
import cn.com.dhcc.turbo.service.registry.BaseInfoService;
/**
 * ftp指标收集
 * @日期：2014-10-10下午2:10:15
 * @作者：张洪涛
 * @版权所有：东华软件
 * @版本：1.0
 */
public class FtpServerQuotaGatherCronJob extends StatefulMethodInvokingJob {
	@SuppressWarnings("deprecation")
	Logger logger = Log.getExistLogger(LOGTYPE.MONITOR);

	@Override
	protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
		logger.info("["+AppConst.installIp+"]"+"定时任务FtpServerQuotaGatherCronJob开始执行....");  
		BaseInfoService baseInfoService=(BaseInfoService) CM.getBeanByName(IocBean.BASE_INFO_SERVICEIMPL_BEAN);
		NodeInfo localNode = null;
		try {
			localNode = baseInfoService.getCurrentNodeInfo();
			if (localNode==null) {
				return;
			}
		} catch (ServiceException e) {
			logger.error("获取本节点信息失败:"+e);
		}
		logger.info("ftp gathering...");
		NetConnStatusGatherService netService = CM.getBean(NetConnStatusGatherService.class);
		netService.netConnStatus();
		FtpServerQuotaGatherService ftpService = CM.getBean(FtpServerQuotaGatherService.class);
		ftpService.ftpConnStatus();
		ftpService.ftpUsedRate();
		logger.info("["+AppConst.installIp+"]"+"定时任务FtpServerQuotaGatherCronJob执行结束...."); 
	}

}
